﻿using AutoMapper;
using Pay.DTO;
using Pay.IService;
using Pay.Core;
using Pay.Data;

namespace Pay.Service.AutoMapper {
	public class BankNumberMapper : IStartupDto {
		private IMapperConfigurationExpression _cfg;
		public BankNumberMapper(IMapperConfigurationExpression cfg) {
			_cfg = cfg;
		}
		public void Execute() {
			Create();
		}
		protected virtual void Create() {
			_cfg.CreateMap<bank_number_dto, BankNumber>()
				.ForMember(dest => dest.BankCode, src => src.MapFrom(c => c.bank_code))
				.ForMember(dest => dest.BranchName, src => src.MapFrom(c => c.branch_name))
				.ForMember(dest => dest.CityId, src => src.MapFrom(c => c.city_id))
				.ForMember(dest => dest.Provinceid, src => src.MapFrom(c => c.province_id));

			_cfg.CreateMap<BankNumber, bank_number_dto>()
				.ForMember(dest => dest.bank_code, src => src.MapFrom(c => c.BankCode))
				.ForMember(dest => dest.branch_name, src => src.MapFrom(c => c.BranchName))
				.ForMember(dest => dest.city_id, src => src.MapFrom(c => c.CityId))
				.ForMember(dest => dest.province_id, src => src.MapFrom(c => c.Provinceid));
		}
	}
}
